﻿CREATE PROCEDURE [ServiceEngine].[GetBinding]
	@ID uniqueidentifier
AS
BEGIN
	SET NOCOUNT ON;

	--SELECT	N.[EntityID] as BindingID, N.[EntityName] as [Name], N.EntityDescription as Description
	--FROM	[ServiceEngine].Bindings B
	--JOIN	[ServiceEngine].Names N on N.[EntityID] = B.BindingID and N.[EntityClass] = 6
	--WHERE	B.BindingID = @ID
	
	--SELECT	BBE.BindingID as BindingID,  BE.ElementConfig, N.[EntityName] as [Name], 
	--N.EntityDescription as Description, BBE.ElementOrder
	SELECT	BBE.BindingID as BindingID, N.[EntityName] as [Name], BE.ElementConfig, 
	N.EntityDescription as Description, BBE.ElementOrder, BBE.BindingElementID, BE.ElementType
	FROM	[ServiceEngine].Bindings_BindingElements BBE
	JOIN	[ServiceEngine].BindingElements BE on BE.[BindingElementID] = BBE.BindingElementID
	JOIN	[ServiceEngine].Names N on N.[EntityID] = BBE.BindingID and N.[EntityTypeID] = 6
	WHERE	BBE.BindingID = @ID
	ORDER BY BBE.ElementOrder 

END


